<?php
class TasksController extends AppController {
	var $name = 'Tasks';
	
	function index() {
    $this->pageTitle = 'Task List';
		$this->set('tasks', $this->Task->find('all', array(
      'conditions' => array('Task.status <> 1'),
    )));
	}
  
  function view($id = null) {
    $this->pageTitle = 'View Task';
    
    $this->Task->id = $id;
    $this->set('task', $this->Task->read());
  }
  
  function add() {
    if (!empty($this->data)) {
      if ($this->Task->save($this->data)) {
        $this->flash('Task saved', '/tasks');
      }
    }
  }
  
  function complete($id = null) {
    $this->Task->id = $id;
    $this->Task->status = 1;
    if ($this->Task->save($this->Task)) {
      $this->flash('Task completed', '/tasks');
    }
  }
}
